package com.mpush.core.chat;

import com.mpush.api.connection.SessionContext;
import com.mpush.netty.http.HttpClient;
import com.mpush.netty.http.NettyHttpClientUtils;
import com.mpush.tools.config.CC;

import java.util.HashMap;
import java.util.Map;

public class ChatUserApi {

    private ChatUserApi(){

    }

    /**
     * 调用用户登录接口
     * @param httpClient
     * @param context
     */
    public static void login(HttpClient httpClient,SessionContext context){

        String uri = "http://" + CC.mp.api.server_address +CC.mp.api.userLogin;

        Map<String, String> param = new HashMap<>(0);
        param.put("userId", context.userId);
        param.put("osName", context.osName);
        param.put("osVersion", context.osVersion);
        param.put("clientVersion", context.clientVersion);
        param.put("deviceId", context.deviceId);

        NettyHttpClientUtils.tryPost(httpClient,uri,param,new DefaultHttpCallback());

    }

    public static void logout(HttpClient httpClient,SessionContext context){

        String uri = "http://" + CC.mp.api.server_address +CC.mp.api.userLogout;

        Map<String, String> param = new HashMap<>(0);
        param.put("userId", context.userId);

        NettyHttpClientUtils.tryPost(httpClient,uri,param,new DefaultHttpCallback());
    }
}
